package com.shadow.study.shiro.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shadow.study.shiro.entity.ShiroRoleEntity;
import com.shadow.study.shiro.mapper.ShiroRoleMapper;
import java.util.Collections;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

@Slf4j
@Service
public class ShiroRoleService extends ServiceImpl<ShiroRoleMapper, ShiroRoleEntity> implements IService<ShiroRoleEntity> {

    @Resource
    private ShiroRoleMapper shiroRoleMapper;

    public List<ShiroRoleEntity> selectByUserId(final Long userId) {
        if (Objects.nonNull(userId)) {
            return shiroRoleMapper.selectByUserId(userId);
        }
        return Collections.emptyList();
    }
}
